package top.fangwenmagician.killfire;

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.data.server.recipe.RecipeJsonProvider;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.tag.ItemTags;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

import java.util.function.Consumer;

public class KillFireDataGen implements DataGeneratorEntrypoint {
    @Override
    public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
//        fabricDataGenerator.addProvider(KillFireGenerator::new);
        fabricDataGenerator.addProvider(KillFireRecipeGenerator::new);
    }

    private static class KillFireRecipeGenerator  extends FabricRecipeProvider {
        private KillFireRecipeGenerator(FabricDataGenerator generator) {
            super(generator);
        }

        @Override
        protected void generateRecipes(Consumer<RecipeJsonProvider> exporter) {
//            ShapelessRecipeJsonBuilder.create(SIMPLE_ITEM).input(SIMPLE_BLOCK).offerTo(exporter);
        }
    }

    private static class KillFireGenerator extends FabricTagProvider<Item> {
        // 创建名为“smelly_items”的物品标签。
        private static final TagKey<Item> SMELLY_ITEMS = TagKey.of(Registry.ITEM_KEY, new Identifier("kill_fire:smelly_items"));

        public KillFireGenerator(FabricDataGenerator dataGenerator) {
            super(dataGenerator, Registry.ITEM);
        }

        @Override
        protected void generateTags() {
            // 创建一个 tag builder，我们添加粘液球、腐肉以及物品标签 minecraft:dirt 中的所有内容。
            getOrCreateTagBuilder(SMELLY_ITEMS)
                    .add(Items.SLIME_BALL)
                    .add(Items.ROTTEN_FLESH)
                    .addOptionalTag(ItemTags.DIRT);
            // 在“generated”文件夹中，会自动生成“assets/mymod/tags/items/smelly_items.json”。
        }
    }
}
